Skip to content

Conversation

@chengkai15
Copy link
Contributor

Implementation Summary
This PR adds full HID Device protocol support to Zephyr's Bluetooth stack, enabling Zephyr devices to function as Bluetooth HID peripherals (e.g., keyboards, mice). The implementation includes:

Core Protocol Infrastructure

Dual L2CAP channel management (Control PSM=0x11, Interrupt PSM=0x13)
Connection manager
Resource initialization system (bt_hid_device_init)
Standardized API for device registration and callbacks
Data Handling

Control channel command processing (SET_REPORT/GET_REPORT)
Interrupt channel report transmission
Input report reception with validation
Support for all HID report types (Input/Output/Feature)
Shell Tool

shell

Connection management
br connect DC:41:A9:XX:XX:XX
hid_device register
hid_device connect
hid_device disconnect

Data operations
hid_device send # Send mouse report

Security & Compliance

HID Spec v1.1.1 compliance
BR/EDR and BLE dual-mode support
Bonding and pairing integration

Add foundational HID device profile implementation:
- Defines standard API:
  • bt_hid_device_register
  • bt_hid_device_connect etc
- Establishes dual L2CAP channels:
  • Control channel (PSM=0x11) for HID commands
  • Interrupt channel (PSM=0x13) for report data
- Manages connection lifecycle:
  • Handles pairing/bonding procedures
  • Tracks connection state transitions
- Implements state reporting via callback:
  • bt_hid_device_register
- Provides resource initialization system:
  • Dynamic context allocation
  • Protocol stack configuration

Signed-off-by: Kai Cheng <[email protected]>
This commit introduces several key components for HID Device support:
1. A shell tool is implemented to interact with the HID Device layer,
   allowing for debugging via command line.
2. Registration of HID Device state callbacks, enabling the application
   to receive connection state changes.
3. Registration of HID SDP service records to support legacy Bluetooth
   devices that use SDP for HID device discovery.
Future work will include the implementation of HID report data
transmission and reception handling.

Signed-off-by: Kai Cheng <[email protected]>
Add handling of incoming data on the HID Control and Interrupt channel.
The received data is parsed according to the HID specification
and passed to the application via the registered HID event callback.
Key changes:
1. Handle HID output reports and control commands.
2. handle HID interrupt data.

Signed-off-by: Kai Cheng <[email protected]>
Add HID device shell module with data reception and send handle.

Signed-off-by: Kai Cheng <[email protected]>
Add robust connection handling for HID device profile:
- Local-initiated connections: bt_hid_connect(addr)
- Local disconnections: bt_hid_disconnect(dev)
- Remote connection handling
- Remote disconnection handling:
- State machine supporting
- Event reporting: disconnected/connected/vc_unplug

Signed-off-by: Kai Cheng <[email protected]>
Implement shell operations for active connection management and
transmission capabilities:
- `hid_device connect`: Initiate connection to peer
- `hid disconnect`: Terminate current connection
- `hid send`: Send HID test data

Signed-off-by: Kai Cheng <[email protected]>
@chengkai15 chengkai15 requested a review from hyson710 as a code owner October 27, 2025 13:51
@github-actions
Copy link

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Nov 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants